package com.demo.statemachine.test1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.statemachine.StateMachine;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StateMachineController {
    @Autowired
    private StateMachine<States, Events> stateMachine;

    @RequestMapping("/pay")
    @ResponseBody
    public void testPay() {
        stateMachine.start();
        stateMachine.sendEvent(Events.PAY);
    }

    @RequestMapping("/receive")
    @ResponseBody
    public void testReceive() {
        stateMachine.start();
        stateMachine.sendEvent(Events.RECEIVE);
    }
}
